import fetch from 'utils/fetch';

export function fetchTree(query) {
  return fetch({
    url: '/api/admin/menu/tree',
    method: 'get',
    params: query
  });
}

export function fetchAll() {
  return fetch({
//  url: 'http://192.168.0.141:8765' + '/api/admin/api/permissions',
		url: '/api' + '/admin/api/user/un/'+ localStorage.getItem('access-userId')+'/menu',
//		url:'/api/admin/api/user/un/'+localStorage.getItem('access-userId') +'/permissions',
    method: 'get',
//  params: { token }
  });
}
export function addObj(obj) {
  return fetch({
    url: '/api/admin/menu',
    method: 'post',
    data: obj
  });
}

export function getObj(id) {
  return fetch({
    url: '/api/admin/menu/' + id,
    method: 'get'
  })
}

export function delObj(id) {
  return fetch({
    url: '/api/admin/menu/' + id,
    method: 'delete'
  })
}

export function putObj(id, obj) {
  return fetch({
    url: '/api/admin/menu/' + id,
    method: 'put',
    data: obj
  })
}
